/**
 * 
 */
package com.desitek.cricket.repository;

import java.util.List;

import com.desitek.cricket.entity.User;

/**
 * @author Dhiraj
 * 
 */
public interface UserRepository extends GenericRepository<User> {

	/**
	 * Get the number of posts sent by an user
	 * 
	 * @param user
	 *            the user
	 * @return the number of posts
	 */
	public int getTotalPosts(User user);

	/**
	 * Gets a specific <code>User</code>.
	 * 
	 * @param username
	 *            The User name to search
	 * @return <code>User</code> object containing all the information or
	 *         <code>null</code> if no data was found.
	 */
	public User getByUsername(String username);

	/**
	 * Checks if the given username is available for registering
	 * 
	 * @param username
	 *            the username to check
	 * @param email
	 *            the email of the given username.
	 * @return true if the username is available, of false if either the
	 *         username or the email address is already taken
	 */
	public boolean isUsernameAvailable(String username, String email);

	public User getUsersById(int id);

	/**
	 * Return all registered users
	 * 
	 * @param start
	 *            the first record to start fetchin
	 * @param count
	 *            how many records to fetch
	 * @return all registered users
	 */
	public List<User> getAllUsers(int start, int count);

	/**
	 * Gets the last registered user in the forum
	 * 
	 * @return the user
	 */
	public User getLastRegisteredUser();

	/**
	 * Get the number of users registered in the forum
	 * 
	 * @return
	 */
	public int getTotalUsers();

	/**
	 * Find a set of users who match an input
	 * 
	 * @param username
	 *            the search input
	 * @return the list of users matching the search input
	 */
	public List<User> findByUserName(String username);

	/**
	 * Autheticates an user
	 * 
	 * @param username
	 *            the username
	 * @param password
	 *            the password
	 * @return an {@link User} instance if sucess, or null otherwise
	 */
	public User validateLogin(String username, String password);

	/**
	 * @param user
	 * @return
	 */
	public int getTotalUnreadPrivateMessages(User user);

	/**
	 * Finds an user by his email
	 * 
	 * @param email
	 *            the email address to search for
	 * @return the user
	 */
	public User getByEmail(String email);

	/**
	 * Validates the lost password hash
	 * 
	 * @param username
	 *            the username associated with the hash
	 * @param hash
	 *            the hash to validate
	 * @return the user instance if the provided infromation matches, or null if
	 *         not.
	 */
	public User validateLostPasswordHash(String username, String hash);

}
